﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using Top.Web.Api;
using Top.Web.Api.Filters;
using Top.Web;
using Top.PointStore.Business.Models;
using Top.PointStore.Business;

namespace Top.PointStore.Controllers
{
    public class AdminController : ApiBase
    {
        [NoLogin]
        [NoIdempotent]
        public object Login()
        {

            if (pUser == null)
            {
                var result = HTML("<script>window.location.href='/oauth/login'</script>");
                return result.GetResponseMessage(this);
            }
            else
            {

                if (pUser.PointStoreAuth == null || pUser.PointStoreAuth.F_IsOpen == 0)
                {
                    return Redirect("/admin/warning.html",false);
                    //throw new WebApiException("此账号没有登录后台权限");
                }
                return Redirect("/admin/index.html", false);
            }
        }

        public object Out()
        {
            Session.Abandon();
            Session.RemoveAll();
            return 1;
        }
    }
}